package edu.itstudy.control;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import edu.itstudy.bean.User;
import edu.itstudy.services.IUserServices;
import edu.itstudy.services.impl.IUserServicesImpl;

public class UserDeleteServlet extends HttpServlet {
	
	private IUserServices iuserServices = new IUserServicesImpl();
	
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	/**
	 * 获取uid
	 * 删除user
	 */
		
		String uid = request.getParameter("uid");	
		int uid_ = 0;
		if(null != uid && !"".equals(uid)) {
			uid_ = Integer.parseInt(uid);
		}
		//物理删除
		//boolean result = iuserServices.deleteUserById(uid_);
		
		//逻辑删除 flag=1 删除  flag=0 正常
		boolean result = iuserServices.updateUserById(uid_, 1);
		
		//向客户相应结果信息
		PrintWriter pw = response.getWriter();
		pw.print(result?1:0);
	}
}
